package com.example.love_margin.Controller;


import com.example.love_margin.Entity.Sale;
import com.example.love_margin.Service.SaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "义卖",tags = "管理义卖")
@RestController
@RequestMapping(value = "/Sale" ,name = "义卖")
@CrossOrigin
public class SaleController {

    @Autowired
    SaleService saleService;

    @ApiOperation(value = "发布义卖信息",notes = "需要：science_title，science_picture，science_type")
    @PostMapping(value = "/addSale")
    public Object addSale(@RequestBody Sale sale){
        return saleService.addSale(sale);
    }

    @ApiOperation(value = "删除义卖信息",notes = "需要：")
    @PostMapping(value = "/deleteSale")
    public Object deleteSale(@RequestParam int sale_id){
        return saleService.deleteSale(sale_id);
    }

    @ApiOperation(value = "查询单个义卖信息",notes = "需要：sale_id")
    @GetMapping(value = "/selectOne")
    public Object selectOne(@RequestParam int sale_id){
        return saleService.selectOne(sale_id);
    }

    @ApiOperation(value = "查询义卖信息列表",notes = "请求即可")
    @GetMapping(value = "/selectAll")
    public Object selectAll(){
        return saleService.selectAll();
    }

    @ApiOperation(value = "修改信息",notes = "需要：science_title，science_picture，science_type")
    @PostMapping(value = "/upSale")
    public Object upSale(@RequestBody Sale sale){
        return saleService.upSale(sale);
    }



}
